package com.shrct.businessprocess.common.impl;

import com.shrct.businessprocess.common.RCTaskProxy;
import com.shrct.businessprocess.common.proxy.RCTaskProxyProxy;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import edu.fudan.langlab.domain.task.Task;
import edu.fudan.langlab.domain.task.impl.TaskImpl;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCTASKPROXY_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rctaskproxy")
public class RCTaskProxyImpl extends BaseModelObject implements RCTaskProxy {
  public RCTaskProxyImpl() {
    super();
  }
  
  @JoinColumn(name = "task_id")
  @ManyToOne(targetEntity = TaskImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private Task task;
  
  public Task getTask() {
    return this.task;
  }
  
  public RCTaskProxy setTask(final Task task) {
    this.task = task;
    return this;			
    
  }
  
  @JoinColumn(name = "owner_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee owner;
  
  public RCEmployee getOwner() {
    return this.owner;
  }
  
  public RCTaskProxy setOwner(final RCEmployee owner) {
    this.owner = owner;
    return this;			
    
  }
  
  public static RCTaskProxy create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.common.RCTaskProxy rCTaskProxy = new com.shrct.businessprocess.common.impl.RCTaskProxyImpl(
    );
    objectFactory.create(rCTaskProxy);
    return rCTaskProxy;			
    
  }
  
  public static RCTaskProxy createRCTaskProxyImpl(final IObjectFactory objectFactory, final Procedure1<RCTaskProxy> init) {
    com.shrct.businessprocess.common.RCTaskProxy rCTaskProxy = new com.shrct.businessprocess.common.impl.RCTaskProxyImpl(
    );
    objectFactory.create(rCTaskProxy);
    init.apply(rCTaskProxy);
    
    return rCTaskProxy;			
    
  }
  
  public RCTaskProxyProxy toProxy() {
    com.shrct.businessprocess.common.proxy.RCTaskProxyProxy proxy = new com.shrct.businessprocess.common.proxy.RCTaskProxyProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
